package Recursion.TowerOfHanoi;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2022-12-03
 * Time: 11:27
 */
public class Hanoi {
    public void Move(int num, char a, char b, char c) {
        if (num == 1) {
            System.out.println(a + "->" + c);
        }else {
            //借助c为中间跳板，先将a上除最大的所有的盘移动到b
            Move(num-1, a, c, b);
            //再把最下面的移动到c
            System.out.println(a + "->" + c);
            //再借助a为中间跳板，先将b上所有的盘移动到c
            Move(num-1, b, a, c);
        }
    }
}
